﻿/// <reference name="MicrosoftAjax.js"/>
/// <reference name="Dimok.Web.UI.JS.JQuery.VSDoc.js" assembly="Dimok.Web.UI" />
/// <reference name="Dimok.Web.UI.JS.MSAjaxExtentions.js" assembly="Dimok.Web.UI" />
/// <reference path="../../JS/UI/Dimok.PageEvents.js" />
Type.registerNamespace("motobankcorp");
motobankcorp.PaymentWaterFall = function(element) {
  motobankcorp.PaymentWaterFall.initializeBase(this, [element]);
  Dimok.AccessorizeType(this);
}
motobankcorp.PaymentWaterFall.prototype = {
  _uploadButton: null,
  _fileUpload: null,
  _wireEvents: function() {
    this.get_RGE().add_rowContextMenuShowing(Function.createDelegate(this, this._onRowContextMenuShowing));
    this.addHandlers(this.get_uploadButton(), { 'click': this._onFileUpload }, this);
  },
  _onFileUpload: function(eventArgs) {
    //if (!parseInt(this.get_interestTypeList().value)) return alert("Select Interest Type first.");
    //if (!parseInt(this.get_paymentTypeList().value)) return alert("Select Payment Type first.");
    $J.ajaxFileUpload({
      fileElementId: this.get_fileUpload().id,
      hiddens: { hdnWaterFallID: eventArgs.target.get_waterFallID() },
      dataType: "html",
      success: Function.createDelegate(this, Function.createDelegate(this, function() { this.rebind(); })),
      url: "/Manager/Settings/Payments/UploadWaterFall.aspx"
    });
    if (!this.set_fileUpload($J(eventArgs.target).parent().find("input:file")[0]))
      alert("File Upload element is not found.\nYou won't be able to upload more file.");
  },
  _onRowContextMenuShowing: function(sender, eventArgs) {
    var id = Dimok.$A(Dimok.$A(eventArgs, true).get_dataKeyValues(), true).get_ID();
    Dimok.AddProperty(this.get_uploadButton(), "waterFallID", id);
  },
  initialize: function() {
    motobankcorp.PaymentWaterFall.callBaseMethod(this, 'initialize');
    Sys.Application.add_load(Function.createDelegate(this, function() {
      this._wireEvents();
    }));
  },
  dispose: function() {
    motobankcorp.PaymentWaterFall.callBaseMethod(this, 'dispose');
  }
}
motobankcorp.PaymentWaterFall.registerClass('motobankcorp.PaymentWaterFall', Dimok.Table);
